<?php
class UserlogController extends Controller {
   public function init() {
        
        parent::init();
        $this->R->module = "用户日志";
    }
    //系统日志控制器
    public function actionIndex() {
        $this->render('index');
    
    }
    //系统日志列表
    public function actionList() {
        $arr = array();
        $page = $this->getParam('page');
        $rows = $this->getParam('rows');
        $criteria = new CDbCriteria();
        $criteria->order = '`Time` desc';
        $count = UserLog::model()->count($criteria);
        $criteria->limit = $rows;
        $criteria->offset = ($page - 1) * $rows;
        $arr['total'] = $count;
        $models = UserLog::model()->findAll($criteria);
        foreach ($models as $m)
        {
            $arr['rows'][] = $m->attributes;
        }
        echo json_encode($arr);exit;
    }
    public function actionDelete(){
        $id = $this->getParam('id');
        $this->R->action = '删除';
        $this->R->noalert = true;
        if (UserLog::model()->deleteByPk($id))
        {
            $this->R->success = true;      
            $this->R->msg = '操作成功';
        }
        else
        {
            $this->R->success = false;
            $this->R->msg = '操作失败';
        }
        $this->R->flush();
    }
}